package com.sb.services;

import org.springframework.dao.DataAccessException;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.sb.model.User;
import com.sb.repositories.UserRepository;

public class UserAuthenticationService implements UserDetailsService {
	
	private UserRepository userRepository;
	
	public UserAuthenticationService(UserRepository userRepository) {
		this.userRepository = userRepository;
	}


	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
		return userRepository.byUserName(username);
	}

}
